<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
  <meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" href="<%=path%>/images/favicon.ico" type="image/ico">
<meta name="author" content="guowenjie">
<link href="<%=path%>/css/bootstrap.min.css" rel="stylesheet">
<link href="<%=path%>/css/materialdesignicons.min.css" rel="stylesheet">
<link href="<%=path%>/css/style.min.css" rel="stylesheet">
<link rel="stylesheet" href="<%=path%>/js/ion-rangeslider/ion.rangeSlider.min.css">
<link href="<%=path%>/js/jconfirm/jquery-confirm.min.css" rel="stylesheet">
<link href="<%=path%>/js/bootstrap-datepicker/bootstrap-datepicker3.min.css" rel="stylesheet">
<link href="<%=path%>/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link href="<%=path%>/css/materialdesignicons.min.css" rel="stylesheet">
<link rel="stylesheet" href="<%=path%>/style/layui/css/layui.css">

<script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
 <script type="text/javascript" src="<%=path%>/js/main.min.js"></script>
<script src="<%=path%>/js/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="<%=path%>/js/bootstrap-datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap-table/bootstrap-table.js"></script>
<script type="text/javascript" src="<%=path%>/js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/jconfirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="<%=path%>/style/layui/layui.js"></script>

</head>
 <div class="container-fluid p-t-15">
    
        <div  class="card">
        <div class="card-header"><h4><a style="color:#33cabb" href="<%=path%>/bg/jcsgl">决策树管理</a><a style="color:#33cabb" href="">/<s:property value="Mname"/></a></h4></div>
       <div class="card-body">
        <div class="row">
           <div id="toolbar" class="toolbar-btn-action">
           <button  type="button" class="btn btn-primary" onclick="newjcs()"><span class="mdi mdi-plus-circle-outline" aria-hidden="true"></span>新增</button>       
           <button id="btn_delete" type="button" class="btn btn-danger"  onclick="del()">
              <span class="mdi mdi-window-close" aria-hidden="true"></span>删除
            </button></div>
     
          <div class="col-md-12">
           <table id="table" ></table>
        </div>
        
            
        </div>
        
      </div></div></div>
      
  
      
   
      
       <script type="text/javascript">
  
       var DMid = "<s:property value="DMid"/>";
       var Mname = "<s:property value="Mname"/>";
       var Jcsid = 0;
       $('#table').bootstrapTable({
    	   classes: 'table table-condensed table-hover',
    		data:[],
    		toolbar: '#toolbar',       // 工具按钮容器	
     	    dataType : 'json',        // 因为本示例中是跨域的调用,所以涉及到ajax都采用jsonp,
    	    columns: [{
 		         checkbox: true    // 是否显示复选框
 		     },{
    	        field: 'Jcsid',
    	        title: '编号'
    	     },{
    	        field: 'Wtdaids',
    	        title: '链路ID'
    	     },{
    	        field: 'Pdyj',
    	        title: '判断依据'
    	     },{
    	        field: 'Pdjl',
    	        title: '判断类型'
    	     },{
    	        field: 'Yjnr',
    	        title: '研究内容'
    	     }],
    	 
    	    onLoadSuccess: function(data){
    	        $("[data-toggle='tooltip']").tooltip();
    	    }
    	});

    search();
   	function search(){
   	$.ajax({
   		 type: "post",//方法类型
   	   dataType: "json",//预期服务器返回的数据类型 jsonp跨域
   		url: "<%=path%>/bg/getjcsmxdata",
   		data:{
   		"DMid":DMid	
   		},
   		success: function(req) {	
   			let data = req.data;
   			if(data.length>0){
   				Jcsid = data[0].Jcsid;
   			}
   			$("#table").bootstrapTable('refreshOptions',{data:data});	 
   		},error: function(e){ 
   			console.log(e);
   			
   		}
   	});
   	}
   	
   	function newjcs(){
   		
   		window.location = "<%=path%>/bg/jcsnew?Mname="+Mname +"&DMid="+DMid+"&Jcsid="+Jcsid;
    	
   		
   	}
    	
     

	function del(){
 	   let row=$("#table").bootstrapTable('getSelections');     
 	 
 	   if(row.length==0){
 		   $.alert({
 	        title: '提示',
 	        content: "请选择要操作的数据"})
    	    }else{
    	    	let Jcsids = new Array();
     		for(var a=0;a<row.length;a++){
     			
     			Jcsids.push(row[a].Jcsid);	
     		}
     		  
     		$.ajax({
	   			 type: "post",//方法类型
	   		    dataType: "json",//预期服务器返回的数据类型 jsonp跨域
	   			url: "<%=path%>/bg/delJcsxx",
	   			data:{
	   				"Jcsids":Jcsids.join(",")
	   			}, 
	   			success: function(req) {
	   		    $.alert({
         	        title: '提示',
         	        content: '操作成功',
         			buttons: {
         				confirm: {
         					text: '确认',
         					btnClass: 'btn-primary',
         					action: function(){
         						search();
         					}
         				}
         			}
         	    });
	   				 
	   			},error: function(e){ 
	   			 console.log(e.responseText);	
	   			}
	   		});
     		
    	    }
    }
   	
      </script>
       </body>

</html>   